/**
  ******************************************************************************
  * @file           : paraupcb.c
  * @brief          : 参数更新回调函数
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "bsp.h"
#include "parameter.h"
#include "measure.h"
#include "gui_asclib.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>

static const char formate_uint[] = "%u";
//static const char formate_uint64[] = "%llu";
static const char formate_ip[] = "%u.%u.%u.%u";
static const char formate_mac[] = "%02X-%02X-%02X-%02X-%02X-%02X";
static const char formate_int[] = "%d";
static const char formate_f4[] = "%.4f";
static const char formate_f3[] = "%.3f";
static const char formate_f2[] = "%.2f";
static const char formate_f1[] = "%.1f";
static const char formate_str[] = "%s";
static const char formate_dt[] = "%04u-%02u-%02u %02u:%02u:%02u";
static const char formate_tm[] = "%02u:%02u:%02u";

/* 首页位置1显示 0班累计 1日累计 2月累计 3年累计 4时累计 5间隔产量 */
uint8_t sto_dynstr_fpointer(main_display_pos1)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  
  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      switch(gv.hr.meas_pa.main_display_pos1)
      {
        default:
        case 0:
          return snprintf(buf, maxlen, formate_str, gui_asc_classacc);
        case 1:
          return snprintf(buf, maxlen, formate_str, gui_asc_dayacc);
        case 2:
          return snprintf(buf, maxlen, formate_str, gui_asc_monthacc);
        case 3:
          return snprintf(buf, maxlen, formate_str, gui_asc_yearacc);
        case 4:
          return snprintf(buf, maxlen, formate_str, gui_asc_houracc);
        case 5:
          return snprintf(buf, maxlen, formate_str, gui_asc_intvacc);
      }
      return 0;
      
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.main_display_pos1);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 首页位置2显示 0流量 1载荷 2速度 */
uint8_t sto_dynstr_fpointer(main_display_pos2)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      switch(gv.hr.meas_pa.main_display_pos2)
      {
        default:
        case 0:
          return snprintf(buf, maxlen, formate_str, gui_asc_liuliang);
        case 1:
          return snprintf(buf, maxlen, formate_str, gui_asc_zaihe);
        case 2:
          return snprintf(buf, maxlen, formate_str, gui_asc_sudu);
      }
      return 0;

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.main_display_pos2);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 显示刷新率 1~20 */
uint8_t sto_dynstr_fpointer(refresh_rate)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.refresh_rate);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 当前班数 */
uint8_t sto_dynstr_fpointer(num_of_class)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.num_of_class+1); /* 当前班数参与运算为0~3,显示为1~4 */

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          temp -= 1;
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16+1);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16+1);

    default:
      return 0;
  }
}

/* 本机编号 */
uint8_t sto_dynstr_fpointer(local_number)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.local_number);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 量程 显示单位(t/h) ÷ 计算单位(t/h) = 0 */
uint8_t sto_dynstr_fpointer(measuring_range_tph)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.measuring_range_tph);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

extern void dc_set_datetime(uint8_t bcd_year, uint8_t bcd_month, uint8_t bcd_day, uint8_t bcd_hour, uint8_t bcd_minute, uint8_t bcd_second);

uint8_t sto_dynstr_fpointer(para_display_time)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t h, m, s;
  
  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, "%02u:%02u:%02u", sys_datatime.hour, sys_datatime.minute, sys_datatime.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          h = temp / 10000;
          m = (temp % 10000) / 100;
          s = temp % 100;

          if((h>23)||(m>59)||(s>59)){
            return 2;
          }
          
          h = __LL_RTC_CONVERT_BIN2BCD(h);
          m = __LL_RTC_CONVERT_BIN2BCD(m);
          s = __LL_RTC_CONVERT_BIN2BCD(s);
          dc_set_datetime(__LL_RTC_CONVERT_BIN2BCD(sys_datatime.year),__LL_RTC_CONVERT_BIN2BCD(sys_datatime.month),__LL_RTC_CONVERT_BIN2BCD(sys_datatime.day), h,m,s);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);
    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(para_display_date)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t y, m, d;
  
  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, "%u-%02u-%02u", sys_datatime.year+2000, sys_datatime.month, sys_datatime.day);
    
    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          y = temp / 10000;
          m = (temp % 10000) / 100;
          d = temp % 100;

          if((y>99)||(y<1)||(m>12)||(m<1)||(d>31)||(d<1)){
            return 2;
          }
          
          y = __LL_RTC_CONVERT_BIN2BCD(y);
          m = __LL_RTC_CONVERT_BIN2BCD(m);
          d = __LL_RTC_CONVERT_BIN2BCD(d);
          dc_set_datetime(y,m,d,__LL_RTC_CONVERT_BIN2BCD(sys_datatime.hour),__LL_RTC_CONVERT_BIN2BCD(sys_datatime.minute),__LL_RTC_CONVERT_BIN2BCD(sys_datatime.second));
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);
    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);
    default:
      return 0;
  }
}

/* 累计分度值 kg enum */
uint8_t sto_dynstr_fpointer(division_kg)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.division_kg);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 自动调零强度 */
uint8_t sto_dynstr_fpointer(auto_zero_range)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.auto_zero_range);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 手动调零强度 */
uint8_t sto_dynstr_fpointer(manu_zero_range)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.manu_zero_range);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 实测速度内码下限 */
uint8_t sto_dynstr_fpointer(speed_low_limit)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.speed_low_limit);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 有效流量下限 显示单位(t/h) ÷ 计算单位(kg/h) = 1000 */
uint8_t sto_dynstr_fpointer(flowrate_lowlim_kgh)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  float ftp;
  int16_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, ((float)gv.hr.meas_pa.flowrate_lowlim_kgh)/1000.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtof(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 1000.0;
          itp = (int16_t)(ftp+0.5);
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f3, ((float)pmt->min.st16)/1000.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f3, ((float)pmt->max.st16)/1000.0);

    default:
      return 0;
  }
}

/* 定量脉冲开关及宽度 显示单位(ms) ÷ 计算单位(ms) = 0 */
uint8_t sto_dynstr_fpointer(weight_pulse_wide)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.weight_pulse_wide);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 定量重量设定 显示单位(t) ÷ 计算单位(kg) = 1000 */
uint8_t sto_dynstr_fpointer(weight_pulse_set_kg)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  double ftp;
  uint32_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, ((double)gv.hr.meas_pa.weight_pulse_set_kg)/1000.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 1000.0;
          itp = (uint32_t)(ftp+0.5);        /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f3, ((double)pmt->min.ut32)/1000.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f3, ((double)pmt->max.ut32)/1000.0);

    default:
      return 0;
  }
}

/* 整圈方式 0定时 1定长 */
uint8_t sto_dynstr_fpointer(len_circle_mode)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME){
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_length);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_time);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.len_circle_mode);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 皮带周期 显示单位(s) ÷ 计算单位(0.01s) = 100 */
uint8_t sto_dynstr_fpointer(belt_period_0d01s)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  double ftp;
  uint32_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f2, ((double)gv.hr.meas_pa.belt_period_0d01s)/100.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 100.0;
          itp = (uint32_t)(ftp+0.5);  /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f2, ((double)pmt->min.ut32)/100.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f2, ((double)pmt->max.ut32)/100.0);

    default:
      return 0;
  }
}

/* 皮带周长 显示单位(m) ÷ 计算单位(mm) = 1000 */
uint8_t sto_dynstr_fpointer(belt_length_mm)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  double ftp;
  uint32_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, ((double)gv.hr.meas_pa.belt_length_mm)/1000.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 1000.0;
          itp = (uint32_t)(ftp+0.5);        /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f3, ((double)pmt->min.ut32)/1000.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f3, ((double)pmt->max.ut32)/1000.0);

    default:
      return 0;
  }
}

/* 称量长度 显示单位(mm) ÷ 计算单位(mm) = 0 */
uint8_t sto_dynstr_fpointer(effect_length_mm)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.effect_length_mm);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 测速轮周长 显示单位(mm) ÷ 计算单位(0.1mm) = 10 */
uint8_t sto_dynstr_fpointer(speed_wheel_cir_0d1mm)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  float ftp;
  uint16_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f1, ((float)gv.hr.meas_pa.speed_wheel_cir_0d1mm)/10.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtof(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 10.0;
          itp = (uint16_t)(ftp+0.5);        /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f1, ((float)pmt->min.ut16)/10.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f1, ((float)pmt->max.ut16)/10.0);

    default:
      return 0;
  }
}

/* 测速轮每周脉冲 */
uint8_t sto_dynstr_fpointer(speed_wheel_pls)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.speed_wheel_pls);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* ao1零点内码(pwm值) ????? */
uint8_t sto_dynstr_fpointer(ao1_zero_code)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.ao1_zero_code);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* ao1满度内码(pwm值) ????? */
uint8_t sto_dynstr_fpointer(ao1_full_code)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.ao1_full_code);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* ao2零点内码(pwm值) ????? */
uint8_t sto_dynstr_fpointer(ao2_zero_code)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.ao2_zero_code);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* ao2满度内码(pwm值) ????? */
uint8_t sto_dynstr_fpointer(ao2_full_code)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.ao2_full_code);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 零点内码上限 */
uint8_t sto_dynstr_fpointer(zero_code_uplimit)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.zero_code_uplimit);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 零点内码 */
uint8_t sto_dynstr_fpointer(zero_code_ave)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.zero_code_ave);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 系数修正使能 */
uint8_t sto_dynstr_fpointer(factor_correct_enable)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.factor_correct_enable != MEAS_FACTOR_CORRECT_DISABLE){
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_on);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_off);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.factor_correct_enable);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 称量系数基础值 */
uint8_t sto_dynstr_fpointer(weight_factor_base)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.weight_factor_base);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 称量系数01 (  >1600   t/h) */
uint8_t sto_dynstr_fpointer(weight_factor01)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.weight_factor01);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 称量系数02 (1200~1600 t/h) */
uint8_t sto_dynstr_fpointer(weight_factor02)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.weight_factor02);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 称量系数03 (800~1200  t/h) */
uint8_t sto_dynstr_fpointer(weight_factor03)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.weight_factor03);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 称量系数04 (400~800   t/h) */
uint8_t sto_dynstr_fpointer(weight_factor04)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.weight_factor04);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 称量系数05 (  <400    t/h) */
uint8_t sto_dynstr_fpointer(weight_factor05)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.weight_factor05);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 校验砝码重量 显示单位(kg) ÷ 计算单位(0.1g) = 10000 */
uint8_t sto_dynstr_fpointer(cal_fama_weight_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  double ftp;
  uint32_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f4, ((double)gv.hr.meas_pa.cal_fama_weight_0d1g)/10000.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 10000.0;
          itp = (uint32_t)(ftp+0.5);        /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f4, ((double)pmt->min.ut32)/10000.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f4, ((double)pmt->max.ut32)/10000.0);

    default:
      return 0;
  }
}

/* 校验实物重量 显示单位(kg) ÷ 计算单位(kg) = 0 */
uint8_t sto_dynstr_fpointer(cal_shiwu_weight_kg)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.cal_shiwu_weight_kg);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 校验实物重量是否计入产量 */
uint8_t sto_dynstr_fpointer(cal_shiwu_wtacc)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.cal_shiwu_wtacc != MEAS_SHIWU_WTACC_NO){
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_yes);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_no);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.cal_shiwu_wtacc);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 校验链码密度 0.1g/m ##### */
uint8_t sto_dynstr_fpointer(cal_lianma_denser_0d1gpm)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  double ftp;
  uint32_t itp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f4, ((double)gv.hr.meas_pa.cal_lianma_denser_0d1gpm)/10000.0);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        ftp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          ftp *= 10000.0;
          itp = (uint32_t)(ftp+0.5);        /* TODO: 范围超限后不应保存 */
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&itp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_f4, ((double)pmt->min.ut32)/10000.0);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_f4, ((double)pmt->max.ut32)/10000.0);

    default:
      return 0;
  }
}

/* 重量内码内给值 */
uint8_t sto_dynstr_fpointer(wad_preset_value)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.wad_preset_value);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.st32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.st32);

    default:
      return 0;
  }
}

/* 重量内码内给开关 */
uint8_t sto_dynstr_fpointer(wad_preset_enable)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.wad_preset_enable != AD_CODE_ACTUAL){
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_ng);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_sc);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.wad_preset_enable);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 速度内码内给值 */
uint8_t sto_dynstr_fpointer(sad_preset_value)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.sad_preset_value);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 速度内码内给开关 */
uint8_t sto_dynstr_fpointer(sad_preset_enable)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.sad_preset_enable != AD_CODE_ACTUAL){
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_ng);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_len_circle_mode_sc);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.sad_preset_enable);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 传感器 速度  地址 */
uint8_t sto_dynstr_fpointer(spd_sensor_addr)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.spd_sensor_addr);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 传感器 称重1 地址 */
uint8_t sto_dynstr_fpointer(wt1_sensor_addr)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.wt1_sensor_addr);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 传感器 称重2 地址 */
uint8_t sto_dynstr_fpointer(wt2_sensor_addr)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.wt2_sensor_addr);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 传感器 称重3 地址 */
uint8_t sto_dynstr_fpointer(wt3_sensor_addr)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.wt3_sensor_addr);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 传感器 称重4 地址 */
uint8_t sto_dynstr_fpointer(wt4_sensor_addr)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.wt4_sensor_addr);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 年累计起始点 */
uint8_t sto_dynstr_fpointer(year_begin_zero)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.year_begin_zero != MEAS_ACC_BEGIN_ZERO_CLASS){
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_0d0f);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_dyb);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.year_begin_zero);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 月累计起始点 */
uint8_t sto_dynstr_fpointer(month_begin_zero)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.month_begin_zero != MEAS_ACC_BEGIN_ZERO_CLASS){
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_0d0f);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_dyb);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.month_begin_zero);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 日累计起始点 */
uint8_t sto_dynstr_fpointer(day_begin_zero)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  uint16_t temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      if(gv.hr.meas_pa.day_begin_zero != MEAS_ACC_BEGIN_ZERO_CLASS){
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_0d0f);
      }else{
        return snprintf(buf, maxlen, formate_str, gui_asc_calzeroready_dyb);
      }

    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, gv.hr.meas_pa.day_begin_zero);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtoul(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut16);

    default:
      return 0;
  }
}

/* 班01累计起时 */
uint8_t sto_dynstr_fpointer(acc_class01_start_time)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t h, m, s;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      return snprintf(buf, maxlen, formate_tm, (gv.hr.meas_pa.acc_class01_start_time/3600), \
                                               ((gv.hr.meas_pa.acc_class01_start_time%3600)/60), \
                                               ((gv.hr.meas_pa.acc_class01_start_time%3600)%60));
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, ((gv.hr.meas_pa.acc_class01_start_time/3600)*10000) + \
                                                 (((gv.hr.meas_pa.acc_class01_start_time%3600)/60)*100) + \
                                                 ((gv.hr.meas_pa.acc_class01_start_time%3600)%60));
    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          h = temp / 10000;
          m = (temp % 10000) / 100;
          s = temp % 100;

          if((h>23)||(m>59)||(s>59)){
            return 2;
          }

          temp = (h * 3600) + (m * 60) + s;

          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      if(maxlen > 0){
        buf[0] = '0';
        return 1;
      }else{
        return 0;
      }

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      if(maxlen >= 6){
        buf[0] = '2';
        buf[1] = '3';
        buf[2] = '5';
        buf[3] = '9';
        buf[4] = '5';
        buf[5] = '9';
        return 6;
      }else{
        return 0;
      }

    default:
      return 0;
  }
}

/* 班02累计起时 */
uint8_t sto_dynstr_fpointer(acc_class02_start_time)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t h, m, s;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      return snprintf(buf, maxlen, formate_tm, (gv.hr.meas_pa.acc_class02_start_time/3600), \
                                               ((gv.hr.meas_pa.acc_class02_start_time%3600)/60), \
                                               ((gv.hr.meas_pa.acc_class02_start_time%3600)%60));
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, ((gv.hr.meas_pa.acc_class02_start_time/3600)*10000) + \
                                                 (((gv.hr.meas_pa.acc_class02_start_time%3600)/60)*100) + \
                                                 ((gv.hr.meas_pa.acc_class02_start_time%3600)%60));
    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          h = temp / 10000;
          m = (temp % 10000) / 100;
          s = temp % 100;

          if((h>23)||(m>59)||(s>59)){
            return 2;
          }

          temp = (h * 3600) + (m * 60) + s;

          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      if(maxlen > 0){
        buf[0] = '0';
        return 1;
      }else{
        return 0;
      }

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      if(maxlen >= 6){
        buf[0] = '2';
        buf[1] = '3';
        buf[2] = '5';
        buf[3] = '9';
        buf[4] = '5';
        buf[5] = '9';
        return 6;
      }else{
        return 0;
      }

    default:
      return 0;
  }
}

/* 班03累计起时 */
uint8_t sto_dynstr_fpointer(acc_class03_start_time)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t h, m, s;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      return snprintf(buf, maxlen, formate_tm, (gv.hr.meas_pa.acc_class03_start_time/3600), \
                                               ((gv.hr.meas_pa.acc_class03_start_time%3600)/60), \
                                               ((gv.hr.meas_pa.acc_class03_start_time%3600)%60));
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, ((gv.hr.meas_pa.acc_class03_start_time/3600)*10000) + \
                                                 (((gv.hr.meas_pa.acc_class03_start_time%3600)/60)*100) + \
                                                 ((gv.hr.meas_pa.acc_class03_start_time%3600)%60));
    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          h = temp / 10000;
          m = (temp % 10000) / 100;
          s = temp % 100;

          if((h>23)||(m>59)||(s>59)){
            return 2;
          }

          temp = (h * 3600) + (m * 60) + s;

          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      if(maxlen > 0){
        buf[0] = '0';
        return 1;
      }else{
        return 0;
      }

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      if(maxlen >= 6){
        buf[0] = '2';
        buf[1] = '3';
        buf[2] = '5';
        buf[3] = '9';
        buf[4] = '5';
        buf[5] = '9';
        return 6;
      }else{
        return 0;
      }

    default:
      return 0;
  }
}

/* 班04累计起时 */
uint8_t sto_dynstr_fpointer(acc_class04_start_time)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;
  uint8_t h, m, s;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
      return snprintf(buf, maxlen, formate_tm, (gv.hr.meas_pa.acc_class04_start_time/3600), \
                                               ((gv.hr.meas_pa.acc_class04_start_time%3600)/60), \
                                               ((gv.hr.meas_pa.acc_class04_start_time%3600)%60));
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_uint, ((gv.hr.meas_pa.acc_class04_start_time/3600)*10000) + \
                                                 (((gv.hr.meas_pa.acc_class04_start_time%3600)/60)*100) + \
                                                 ((gv.hr.meas_pa.acc_class04_start_time%3600)%60));
    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          h = temp / 10000;
          m = (temp % 10000) / 100;
          s = temp % 100;

          if((h>23)||(m>59)||(s>59)){
            return 2;
          }

          temp = (h * 3600) + (m * 60) + s;

          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      if(maxlen > 0){
        buf[0] = '0';
        return 1;
      }else{
        return 0;
      }

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      if(maxlen >= 6){
        buf[0] = '2';
        buf[1] = '3';
        buf[2] = '5';
        buf[3] = '9';
        buf[4] = '5';
        buf[5] = '9';
        return 6;
      }else{
        return 0;
      }

    default:
      return 0;
  }
}

/* 上次总累计清零切换日期 */
uint8_t sto_dynstr_fpointer(total_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_total_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_total_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_total_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_total_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_total_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_total_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_uint, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_uint, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 上次年累计清零切换日期 */
uint8_t sto_dynstr_fpointer(year_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_year_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_year_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_year_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_year_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_year_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_year_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 上次月累计清零切换日期 */
uint8_t sto_dynstr_fpointer(month_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_month_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_month_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_month_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_month_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_month_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_month_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 上次日累计清零切换日期 */
uint8_t sto_dynstr_fpointer(day_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_day_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_day_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_day_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_day_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_day_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_day_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 上次时累计清零切换日期 */
uint8_t sto_dynstr_fpointer(hour_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_hour_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_hour_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_hour_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_hour_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_hour_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_hour_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(class_last_switch)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_dt, gv.ir.meas_ca.wtacc_class_last_switch.year, \
                                               gv.ir.meas_ca.wtacc_class_last_switch.month, \
                                               gv.ir.meas_ca.wtacc_class_last_switch.day, \
                                               gv.ir.meas_ca.wtacc_class_last_switch.hour, \
                                               gv.ir.meas_ca.wtacc_class_last_switch.minute, \
                                               gv.ir.meas_ca.wtacc_class_last_switch.second);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 总累计 */
uint8_t sto_dynstr_fpointer(total_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.total_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 年累计 */
uint8_t sto_dynstr_fpointer(year_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.year_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}
/* 月累计 */
uint8_t sto_dynstr_fpointer(month_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.month_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}
/* 日累计 */
uint8_t sto_dynstr_fpointer(day_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.day_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}
/* 时累计 */
uint8_t sto_dynstr_fpointer(hour_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.hour_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}
/* 脉冲累计 */
uint8_t sto_dynstr_fpointer(pulse_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.pulse_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(class01_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class01_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(class02_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class02_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(class03_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class03_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

uint8_t sto_dynstr_fpointer(class04_acc_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class04_acc_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 累计全部清零 仅显示 不存储 */
uint8_t sto_dynstr_fpointer(acc_all_clear)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      if(maxlen > 2){
        buf[0] = '0';
        buf[1] = '\0';
        return 1; 
      }
      return 0;

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        if(buf[0] == '1'){
          gv.co.meas_ec.acc_all_clear_key = MEAS_ACC_ALL_CLEAR_KEY;
          return STO_DO_NOT_SAVE_NOERR;
        }else{
          return 1;
        }
      }
      return 2;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 总累计_上次 */
uint8_t sto_dynstr_fpointer(total_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.total_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 年累计_上次 */
uint8_t sto_dynstr_fpointer(year_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.year_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 月累计_上次 */
uint8_t sto_dynstr_fpointer(month_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.month_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 日累计_上次 */
uint8_t sto_dynstr_fpointer(day_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.day_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 时累计_上次 */
uint8_t sto_dynstr_fpointer(hour_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.hour_acc_last_0d1g/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 班01累计_上次 */
uint8_t sto_dynstr_fpointer(class01_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class01_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 班02累计_上次 */
uint8_t sto_dynstr_fpointer(class02_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class02_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 班03累计_上次 */
uint8_t sto_dynstr_fpointer(class03_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class03_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 班04累计_上次 */
uint8_t sto_dynstr_fpointer(class04_acc_last_0d1g)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_f3, (double)(gv.ir.meas_ca.class04_acc_last_kg/1000.0));

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtod(buf, &endptr);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          if(temp < 0){
            return 2;
          }
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
    case STO_MTDYNSTR_OUTPUT_MAXVA:
    default:
      return 0;
  }
}

/* 市名/编号 */
uint8_t sto_dynstr_fpointer(prod_city_num)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_city_num);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 县名/编号 */
uint8_t sto_dynstr_fpointer(prod_county_num)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_county_num);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 矿名/编号 */
uint8_t sto_dynstr_fpointer(prod_mines_num)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_mines_num);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 核定年生产能力 */
uint8_t sto_dynstr_fpointer(prod_year_capacity_t)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_year_capacity_t);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 核定月生产能力 */
uint8_t sto_dynstr_fpointer(prod_month_capacity_t)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_month_capacity_t);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 核定日生产能力 */
uint8_t sto_dynstr_fpointer(prod_day_capacity_t)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_day_capacity_t);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 核定时生产能力 */
uint8_t sto_dynstr_fpointer(prod_hour_capacity_t)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_hour_capacity_t);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 间隔参量时间 也是上传时间 */
uint8_t sto_dynstr_fpointer(prod_interval_time_s)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_interval_time_s);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 产量网络发送超时时间 */
uint8_t sto_dynstr_fpointer(prod_net_timeout_s)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.prod_net_timeout_s);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut32);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut32);

    default:
      return 0;
  }
}

/* 本机IP  u8x4 */
uint8_t sto_dynstr_fpointer(eth_local_ip)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;
  
  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_local_ip[0], gv.hr.meas_pa.eth_local_ip[1], \
                                               gv.hr.meas_pa.eth_local_ip[2], gv.hr.meas_pa.eth_local_ip[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* 网关    u8x4 */
uint8_t sto_dynstr_fpointer(eth_local_gw)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_local_gw[0], gv.hr.meas_pa.eth_local_gw[1], \
                                               gv.hr.meas_pa.eth_local_gw[2], gv.hr.meas_pa.eth_local_gw[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* 子网掩码 u8x4 */
uint8_t sto_dynstr_fpointer(eth_local_msk)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_local_msk[0], gv.hr.meas_pa.eth_local_msk[1], \
                                               gv.hr.meas_pa.eth_local_msk[2], gv.hr.meas_pa.eth_local_msk[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* 本机MAC u8x6 */
uint8_t sto_dynstr_fpointer(eth_local_mac)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_mac, gv.hr.meas_pa.eth_local_mac[0], gv.hr.meas_pa.eth_local_mac[1], \
                                                gv.hr.meas_pa.eth_local_mac[2], gv.hr.meas_pa.eth_local_mac[3], \
                                                gv.hr.meas_pa.eth_local_mac[4], gv.hr.meas_pa.eth_local_mac[5]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_mac, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3], pmt->min.ua8[4], pmt->min.ua8[5]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_mac, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3], pmt->max.ua8[4], pmt->max.ua8[5]);

    default:
      return 0;
  }
}
/* 间隔参量上传 目标服务器ip u8x4 */
uint8_t sto_dynstr_fpointer(eth_produp_ip)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_produp_ip[0], gv.hr.meas_pa.eth_produp_ip[1], \
                                               gv.hr.meas_pa.eth_produp_ip[2], gv.hr.meas_pa.eth_produp_ip[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* 实时参量上传 目标服务器ip u8x4 */
uint8_t sto_dynstr_fpointer(eth_prodrt_ip)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_prodrt_ip[0], gv.hr.meas_pa.eth_prodrt_ip[1], \
                                               gv.hr.meas_pa.eth_prodrt_ip[2], gv.hr.meas_pa.eth_prodrt_ip[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* modbusTCP  目标服务器ip u8x4 */
uint8_t sto_dynstr_fpointer(eth_mbtcp_ip)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int a[4];
  uint8_t ip[4];
  uint8_t n;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_ip, gv.hr.meas_pa.eth_mbtcp_ip[0], gv.hr.meas_pa.eth_mbtcp_ip[1], \
                                               gv.hr.meas_pa.eth_mbtcp_ip[2], gv.hr.meas_pa.eth_mbtcp_ip[3]);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        a[0] = 256;
        a[1] = 256;
        a[2] = 256;
        a[3] = 256;
        n = _sscanf(buf, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]);
        if(n == 4)
        {
          if((a[0]>=0)&&(a[0]<256)&&(a[1]>=0)&&(a[1]<256)&&(a[2]>=0)&&(a[2]<256)&&(a[3]>=0)&&(a[3]<256))
          {
            ip[0]= a[0];
            ip[1]= a[1];
            ip[2]= a[2];
            ip[3]= a[3];
            sto_update_item(pmt->idx, (const Sto_CellUnion*)&ip, 0);
            return 0;
          }
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_ip, pmt->min.ua8[0], pmt->min.ua8[1], pmt->min.ua8[2], pmt->min.ua8[3]);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_ip, pmt->max.ua8[0], pmt->max.ua8[1], pmt->max.ua8[2], pmt->max.ua8[3]);

    default:
      return 0;
  }
}
/* 间隔参量上传 目标服务器端口 */
uint8_t sto_dynstr_fpointer(eth_produp_port)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.eth_produp_port);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut16);

    default:
      return 0;
  }
}
/* 实时参量上传 目标服务器端口 */
uint8_t sto_dynstr_fpointer(eth_prodrt_port)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.eth_prodrt_port);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut16);

    default:
      return 0;
  }
}
/* modbusTCP  目标服务器端口 */
uint8_t sto_dynstr_fpointer(eth_mbtcp_prot)(const Sto_MaintainStru *pmt, uint8_t type, char *buf, uint16_t maxlen)
{
  int temp;
  char *endptr = NULL;

  switch(type)
  {
    case STO_MTDYNSTR_OUTPUT_VALUE:
    case STO_MTDYNSTR_OUTPUT_SRCVALUE:
      return snprintf(buf, maxlen, formate_int, gv.hr.meas_pa.eth_mbtcp_prot);

    case STO_MTDYNSTR_INPUT_VALUE:
      if((buf != NULL) && (maxlen > 0))
      {
        temp = strtol(buf, &endptr, 10);
        if((*endptr == '\0') && (endptr > buf) && (endptr <= (buf+maxlen)) && (errno == 0))
        {
          sto_update_item(pmt->idx, (const Sto_CellUnion*)&temp, errno);
          return 0;
        }
      }
      return 1;

    case STO_MTDYNSTR_OUTPUT_MINVA:
      return snprintf(buf, maxlen, formate_int, pmt->min.ut16);

    case STO_MTDYNSTR_OUTPUT_MAXVA:
      return snprintf(buf, maxlen, formate_int, pmt->max.ut16);

    default:
      return 0;
  }
}
